//
//  ZH_MineBankCardTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/23.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineBankCardTableViewCell.h"
@interface ZH_MineBankCardTableViewCell()
@property (nonatomic,weak)UILabel *leftLabel;
@property (nonatomic,weak)UIImageView *rightImage;
@property (nonatomic,weak)UITextField *textField;
@end
@implementation ZH_MineBankCardTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MineBankCardTableViewCell";
    ZH_MineBankCardTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MineBankCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(18));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-17));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
    }];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
        make.width.mas_equalTo(FITSCALE(9));
        make.height.mas_equalTo(FITSCALE(14));
    }];
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(FITSCALE(95));
//        make.right.equalTo(self.contentView).offset(FITSCALE(-40));
//        make.left.equalTo(self.leftLabel.mas_right);
        make.right.equalTo(self.rightImage.mas_left);
    }];
}
- (void)setLeftString:(NSString *)leftString{
    self.leftLabel.text = leftString;
}
- (void)rightImageHidden:(BOOL)isbool{
    self.rightImage.hidden = isbool;
}
- (void)textFieldHidden:(BOOL)isbool{
    self.textField.hidden =isbool;
}
- (void)setPloderString:(NSString *)ploderString{
    self.textField.placeholder = ploderString;
}
- (void)updateUI{
    [self.textField mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(FITSCALE(105));
    }];
}
///输入框 回调 方法
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    //    if(self.onEnterTextFieldBlock){
    //        self.onEnterTextFieldBlock(textField.text, textField.tag);
    //    }
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.textField endEditing:YES];
    return YES;
}
#pragma mark - getter,setter
- (UILabel *)leftLabel{
    if (!_leftLabel) {
        UILabel *label = [UILabel createLabelWithText:@"" font:kFontSize_30];
        [self.contentView addSubview:_leftLabel = label];
    }
    return _leftLabel;
}
- (UIImageView *)rightImage{
    if (!_rightImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_mygetmore1"];
        [self.contentView addSubview:_rightImage = image];
    }
    return _rightImage;
}
- (UITextField *)textField
{
    if(!_textField){
        UITextField *textField = [UITextField createTextFieldWithPlaceholder:@"" placeholderColor:kFontColorGray delegateTarget:self];
        textField.borderStyle = UITextBorderStyleNone;
        textField.font = kFontSize_28;
        textField.textAlignment = NSTextAlignmentLeft;
        textField.returnKeyType = UIReturnKeyDone;
        [textField setTextColor:kFontColorBlack];
        [self.contentView addSubview:_textField = textField];
    }
    return _textField;
}

@end
